package myRules;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.HashSet;
import java.util.List;

import se.lth.eit.eit060.proj2.initiation.Utility;

public class Person extends HashSet<String>{
	//Only doctor has associated. Which is patients whom he has treated.
	private String division;
	private String title;
	private String name;
	private String password;
	private String phone;
	private int failed=0;
	
	public Person(String name, String divison, String title, String password, String phone){
		password = Utility.hashCode(password);
		this.division = divison;
		this.title = title;
		this.name = name;
		this.password = password;
		this.phone = phone;
	}
	
	public Person(String name, String divison, String title, String password, String phone,int failed){
		this.division = divison;
		this.title = title;
		this.name = name;
		this.password = password;
		this.phone = phone;
		this.failed=failed;
	}
	
	public String getDivision(){
		if(title.equals(Utility.Patient)){
			return "NONE";
		}else{
			return division;
		}
	}
	
	public String getTitle(){
		return title;
	}
	
	public String getName(){
		return name;
	}
	
	public boolean comparePassword(String pwd){
		System.out.println(password);
		System.out.println(Utility.hashCode(pwd));
		boolean b = password.equals(Utility.hashCode(pwd));
		if(failed>5){
		return false;
		}
		if(!b){
			failed++;
		}else{
			failed=0;
		}
		return b;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public int getFailed() {
		return failed;
	}

	public void setFailed(int failed) {
		this.failed = failed;
	}
	

	public String toString(){
		return title+" "+name;
	}
	
}
